<template>
  <div>
    <hr>
<button @click="add">随机显示名字</button>
<p>{{ arr[i] }}</p>
  </div>
</template>

<script>
export default {
data () {
  return {
    arr:["小花", "小明", "小可爱", "小王"],
    i:''
  }
},
methods: {
  add(){
   this.i=Math.floor((Math.random()*this.arr.length))
  }
}
}
</script>

<style>

</style>